<?php

/*
 * 作者:liuleyi
 * 功能描述:商品类控制器
 * 修改记录
 * 修改时间   修改人     修改描述
 */

namespace Admin\Controller;

use Think\Controller;

class GoodsCategoryController extends Controller {
    /*
      public function add() {
      if (!empty($_POST)) {

      // $func = new \Admin\Func\Func901010101(I('OperatorID'), I('OperatorName'), I('LoginPasswd'));
      $func = new \Admin\Func\Func902010101(I('GoodsCategoryId'), I('GoodsCategoryName'), I('GoodsCategoryDesc'));
      if ($func->execute() === false) {
      $this->error("新增失败:" . $func->getErrMsg());
      } else {
      // $this->display();
      $this->success('新增成功！');
      }
      //  $this->display();
      } else {
      $this->display();
      }
      }
     */

    public function add() {

        if (!empty($_POST)) {

            $func = new \Admin\Func\Func902010101(I('GoodsCategoryId'), I('GoodsCategoryName'), I('GoodsCategoryDesc'));
           
            if ($func->execute() === false) {
               // $this->display();
                   $this->error("新增失败:" . $func->getErrMsg());
            } else {
                // $this->display();
                 $this->success('新增成功！');
            }
            //  $this->display();
        } else {
            $this->display();
        }
    }

    public function del($GoodsCategoryId) {
        $func = new \Admin\Func\Func902010103($GoodsCategoryId);
        if ($func->execute() === false) {
            $this->error('删除失败' . $func->getErrMsg());
        } else {
            $this->redirect('GoodsCategory/lst');
        }
    }

    public function edit($GoodsCategoryId) {
        if (!empty($_POST)) {
            $func = new \Admin\Func\Func902010102(I('GoodsCategoryId'), I('GoodsCategoryName'), I('GoodsCategoryDesc'));
            if ($func->execute() === false) {
                $this->error("编辑失败:" . $func->getErrMsg());
            } else {
                $this->success('编辑成功！');
            }
        } else {

            $func = new \Admin\Func\Func902010104($GoodsCategoryId);
            if ($func->execute() === false) {
                $this->error('查询失败:' . $func->getErrMsg());
            } else {
               // show_bug($func->getRst()[0]);
                $this->assign('post', $func->getRst()[0]);
                $this->display();
            }
        }
    }

    public function lst() {
        $func = new \Admin\Func\Func902010105(I('GoodsCategoryName'), I('GoodsCategoryDesc'));
        if ($func->execute() === false) {
            $this->error('查询失败:' . $func->getErrMsg());
        } else {

            $this->assign('lst', $func->getRst());
        }
        $this->display();
    }

}
